package com.fishery.base.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fishery.base.entity.GermchitType;
import com.fishery.base.mapper.GermchitTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GermchitTypeDataListener extends AnalysisEventListener<GermchitType> {

	@Autowired
	private GermchitTypeMapper germchitTypeMapper;

	@Override
	public void invoke(GermchitType germchitType, AnalysisContext analysisContext) {
		// 直接删除数据库原先存在该种种类到信息
		germchitTypeMapper.deleteGermchitTypeByName(germchitType.getName());
		// 将数据保存到数据库中
		germchitTypeMapper.insert(germchitType);
	}

	@Override
	public void doAfterAllAnalysed(AnalysisContext analysisContext) {
	}
}
